#include "event.h"
 
Event::Event() {
}
 
Event::~Event() {
    //Do nothing
}
 
void Event::OnEvent(SDL_Event* evnt) {
    switch(evnt->type) {
        case SDL_ACTIVEEVENT: {
            switch(evnt->active.state) {
                case SDL_APPMOUSEFOCUS: {
                    if ( evnt->active.gain )    OnMouseFocus();
                    else                OnMouseBlur();
 
                    break;
                }
                case SDL_APPINPUTFOCUS: {
                    if ( evnt->active.gain )    OnInputFocus();
                    else                OnInputBlur();
 
                    break;
                }
                case SDL_APPACTIVE:    {
                    if ( evnt->active.gain )    OnRestore();
                    else                OnMinimize();
 
                    break;
                }
            }
            break;
        }
 
        case SDL_KEYDOWN: {
            OnKeyDown(evnt->key.keysym.sym,evnt->key.keysym.mod,evnt->key.keysym.unicode);
            break;
        }
 
        case SDL_KEYUP: {
            OnKeyUp(evnt->key.keysym.sym,evnt->key.keysym.mod,evnt->key.keysym.unicode);
            break;
        }
 
        case SDL_MOUSEMOTION: {
            OnMouseMove(evnt->motion.x,evnt->motion.y,evnt->motion.xrel,evnt->motion.yrel,(evnt->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(evnt->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(evnt->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0);
            break;
        }
 
        case SDL_MOUSEBUTTONDOWN: {
            switch(evnt->button.button) {
                case SDL_BUTTON_LEFT: {
                    OnLButtonDown(evnt->button.x,evnt->button.y);
                    break;
                }
                case SDL_BUTTON_RIGHT: {
                    OnRButtonDown(evnt->button.x,evnt->button.y);
                    break;
                }
                case SDL_BUTTON_MIDDLE: {
                    OnMButtonDown(evnt->button.x,evnt->button.y);
                    break;
                }
            }
            break;
        }
 
        case SDL_MOUSEBUTTONUP:    {
            switch(evnt->button.button) {
                case SDL_BUTTON_LEFT: {
                    OnLButtonUp(evnt->button.x,evnt->button.y);
                    break;
                }
                case SDL_BUTTON_RIGHT: {
                    OnRButtonUp(evnt->button.x,evnt->button.y);
                    break;
                }
                case SDL_BUTTON_MIDDLE: {
                    OnMButtonUp(evnt->button.x,evnt->button.y);
                    break;
                }
            }
            break;
        }
 
        case SDL_JOYAXISMOTION: {
            OnJoyAxis(evnt->jaxis.which,evnt->jaxis.axis,evnt->jaxis.value);
            break;
        }
 
        case SDL_JOYBALLMOTION: {
            OnJoyBall(evnt->jball.which,evnt->jball.ball,evnt->jball.xrel,evnt->jball.yrel);
            break;
        }
 
        case SDL_JOYHATMOTION: {
            OnJoyHat(evnt->jhat.which,evnt->jhat.hat,evnt->jhat.value);
            break;
        }
        case SDL_JOYBUTTONDOWN: {
            OnJoyButtonDown(evnt->jbutton.which,evnt->jbutton.button);
            break;
        }
 
        case SDL_JOYBUTTONUP: {
            OnJoyButtonUp(evnt->jbutton.which,evnt->jbutton.button);
            break;
        }
 
        case SDL_QUIT: {
            Exit();
            break;
        }
 
        case SDL_SYSWMEVENT: {
            //Ignore
            break;
        }
 
        case SDL_VIDEORESIZE: {
            OnResize(evnt->resize.w,evnt->resize.h);
            break;
        }
 
        case SDL_VIDEOEXPOSE: {
            OnExpose();
            break;
        }
 
        default: {
            OnUser(evnt->user.type,evnt->user.code,evnt->user.data1,evnt->user.data2);
            break;
        }
    }
}
 
void Event::OnInputFocus() {
    //Pure virtual, do nothing
}
 
void Event::OnInputBlur() {
    //Pure virtual, do nothing
}
 
void Event::OnKeyDown(SDLKey sym, SDLMod mod, Uint16 unicode) {
    //Pure virtual, do nothing
}
 
void Event::OnKeyUp(SDLKey sym, SDLMod mod, Uint16 unicode) {
    //Pure virtual, do nothing
}
 
void Event::OnMouseFocus() {
    //Pure virtual, do nothing
}
 
void Event::OnMouseBlur() {
    //Pure virtual, do nothing
}
 
void Event::OnMouseMove(int mX, int mY, int relX, int relY, bool Left,bool Right,bool Middle) {
    //Pure virtual, do nothing
}
 
void Event::OnMouseWheel(bool Up, bool Down) {
    //Pure virtual, do nothing
}
 
void Event::OnLButtonDown(int mX, int mY) {
    //Pure virtual, do nothing
}
 
void Event::OnLButtonUp(int mX, int mY) {
    //Pure virtual, do nothing
}
 
void Event::OnRButtonDown(int mX, int mY) {
    //Pure virtual, do nothing
}
 
void Event::OnRButtonUp(int mX, int mY) {
    //Pure virtual, do nothing
}
 
void Event::OnMButtonDown(int mX, int mY) {
    //Pure virtual, do nothing
}
 
void Event::OnMButtonUp(int mX, int mY) {
    //Pure virtual, do nothing
}
 
void Event::OnJoyAxis(Uint8 which,Uint8 axis,Sint16 value) {
    //Pure virtual, do nothing
}
 
void Event::OnJoyButtonDown(Uint8 which,Uint8 button) {
    //Pure virtual, do nothing
}
 
void Event::OnJoyButtonUp(Uint8 which,Uint8 button) {
    //Pure virtual, do nothing
}
 
void Event::OnJoyHat(Uint8 which,Uint8 hat,Uint8 value) {
    //Pure virtual, do nothing
}
 
void Event::OnJoyBall(Uint8 which,Uint8 ball,Sint16 xrel,Sint16 yrel) {
    //Pure virtual, do nothing
}
 
void Event::OnMinimize() {
    //Pure virtual, do nothing
}
 
void Event::OnRestore() {
    //Pure virtual, do nothing
}
 
void Event::OnResize(int w,int h) {
    //Pure virtual, do nothing
}
 
void Event::OnExpose() {
    //Pure virtual, do nothing
}
 
void Event::Exit() {
    //Pure virtual, do nothing
}
 
void Event::OnUser(Uint8 type, int code, void* data1, void* data2) {
    //Pure virtual, do nothing
}